package cn.imvc.app.controllers.order;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import cn.imvc.app.domains.OrderState;
import cn.imvc.app.domains.OrderType;
import cn.imvc.app.entities.Goods;
import cn.imvc.app.entities.GoodsOrder;
import cn.imvc.app.entities.Orders;
import cn.imvc.app.models.GoodsOrderModel;
import cn.imvc.app.models.LoggingModel;
import cn.imvc.app.models.OrdersModel;
import cn.imvc.app.repositories.GoodsOrderRepository;
import cn.imvc.core.DialogBean;
import cn.imvc.core.Render;
import cn.imvc.data.domain.ViewRequest;

public class GoodsOrderControllerImpl implements GoodsOrderController {
	static Logger logger = Logger.getLogger(GoodsOrderControllerImpl.class);
	@Autowired
	OrdersModel ordersModel;
	@Autowired
	GoodsOrderModel goodsOrderModel;
	@Autowired
	LoggingModel loggingModel;
	
	public Page<Orders> page;
	public Goods goods;
	public Orders orders;
	public GoodsOrder goodsOrder;
	public ViewRequest viewRequest;
	public int id;
	public int[] ids;
	public Map<Byte, String> orderState = OrderState.elMap;
	
	public void setOrdersModel(OrdersModel ordersModel) {
		this.ordersModel = ordersModel;
	}

	public void setPage(Page<Orders> page) {
		this.page = page;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	public void setOrders(Orders orders) {
		this.orders = orders;
	}

	public void setViewRequest(ViewRequest viewRequest) {
		this.viewRequest = viewRequest;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setIds(int[] ids) {
		this.ids = ids;
	}

	public void setOrderState(Map<Byte, String> orderState) {
		this.orderState = orderState;
	}

	public String search() {
		// TODO Auto-generated method stub
		return null;
	}

	public String index() {
		// TODO Auto-generated method stub
		return null;
	}

	public String show() {
		// TODO Auto-generated method stub
		return null;
	}

	public String editNew() {
		// TODO Auto-generated method stub
		return null;
	}

	public String create() {
		// TODO Auto-generated method stub
		return null;
	}

	public String edit() {
		// TODO Auto-generated method stub
		return null;
	}

	public String update() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String destroy() {
		// TODO Auto-generated method stub
		return null;
	}

	public String destroyBatch() {
		// TODO Auto-generated method stub
		return null;
	}

	public String deliveryfailed() {
		boolean state =  goodsOrderModel.updateDeliveryFailed(id);
		if(state){
			loggingModel.info(logger, "设为出货失败:"+id);
			return Render.json(new DialogBean("200", "设为出货失败","orders_show"));
		}else{
			return Render.json(new DialogBean("300", "订单状态异常，不能设为出货失败","orders_show"));
		}
	}

}
